#! /bin/bash

# Plot Data function
# ------------------------------------------------------------------------------
plot_data()
{
    if [ $# -ne 8 ]; then
        echo "plot_data(): incorrect number of function arguments!"
        echo "usage: plot_data [type] [data path] [plot path] [title] [x lab] [y lab] [xmin] [xmax]"
    fi
    type=$1     # type of data to plot
    data=$2     # the data file (full path)
    plot=$3     # the output plot file (excluding file type, full path)
    title=$4    # plot title
    xLab=$5     # plot x label
    yLab=$6     # plot y label
    xmin=$7     # plot x min value
    xmax=$8     # plot y min value
    opts="-d png -r 96"
    echo "*********************************************************************"
    echo "* Creating plot $plot"
    echo "*********************************************************************"
    if [ $type = "t" ]; then
        gle $opts -o $plot plotTimes.gle $data "$title" "$xLab" "$yLab" $xmin $xmax
    elif [ $type = "a" ]; then
        gle $opts -o $plot plotSpectAmp.gle $data "$title" "$xLab" "$yLab" $xmin $xmax
    elif [ $type = "p" ]; then
        gle $opts -o $plot plotSpectPeriod.gle $data "$title" "$xLab" "$yLab" $xmin $xmax
    elif [ $type = "s" ]; then
        gle $opts -o $plot plotSpect.gle $data "$title" "$xLab" "$yLab" $xmin $xmax
    else 
        echo "unknown plot type!"
        exit 1
    fi
    png2eps2 ${plot}.png
}

